home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWStream / Include / FWStrmRW.h < prev   
Encoding:
C/C++ Source or Header  |  1995-11-08  |  33.0 KB  |  1,081 lines  |  [TEXT/MPS ]

  1. #ifndef FWSTRMRW_H
  2. #define FWSTRMRW_H
  3. //========================================================================================
  4. //
  5. //    File:                FWStrmRW.h
  6. //    Release Version:    $ 1.0d11 $
  7. //
  8. //    Copyright:    (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWASINKS_H
  13. #include "FWASinks.h"
  14. #endif
  15.  
  16. #ifndef FWSTRMF_H
  17. #include "FWStrmF.h"
  18. #endif
  19.  
  20. #if FW_LIB_EXPORT_PRAGMAS
  21. #pragma lib_export on
  22. #endif
  23.  
  24. //========================================================================================
  25. // Forward class declarations
  26. //========================================================================================
  27.  
  28. class FW_CLASS_ATTR FW_CObjectRegistry;
  29.  
  30.  
  31. //========================================================================================
  32. //    CLASS FW_CReadableStream
  33. //========================================================================================
  34.  
  35. class FW_CLASS_ATTR FW_CReadableStream FW_AUTO_DESTRUCT_OBJECT
  36. {
  37.  
  38. public:
  39.  
  40.     typedef void* (* InputFunction)(FW_CReadableStream& readableStream);
  41.  
  42.     FW_CReadableStream(FW_CSink* sink,
  43.                        FW_CReadableStreamFormatter* formatter = 0,
  44.                        FW_CObjectRegistry* objectRegistry = 0);
  45.     virtual ~ FW_CReadableStream();
  46.  
  47.     void* InputObject(InputFunction inputFunction);
  48.         // Reads object data for static and dynamic classes from the readableStream.
  49.  
  50.     FW_CSink*    GetSink() const;
  51.  
  52.     // ----- void
  53.     
  54.     void Read(void* buffer,
  55.               long count) const;
  56.         // Read 'count' bytes into buffer.
  57.  
  58.     // ----- char
  59.     
  60. //#if !defined(__BORLANDC__)
  61.     // Borland doesn't treat char, unsigned char and signed char as three distinct types
  62.     // as it should. (ARM pg. 22)
  63.     void Read(char* buffer,
  64.               long count) const;
  65.         // Read 'count' chars into buffer.
  66.  
  67.     const FW_CReadableStream& operator>>(char& aChar) const;
  68.         // Read char.
  69. //#endif
  70.  
  71.     const FW_CReadableStream& operator>>(char* nullTerminatedString) const;
  72.         // Read a null-terminated string.
  73.         
  74.     char GetChar() const;
  75.         // Get char.
  76.  
  77.     // ----- signed char
  78.     
  79.     void Read(signed char* buffer,
  80.               long count) const;
  81.         // Read 'count' signed chars into buffer.
  82.  
  83.     const FW_CReadableStream& operator>>(signed char& aChar) const;
  84.         // Read char.
  85.  
  86.     signed char GetSignedChar() const;
  87.         // Get signed char.
  88.  
  89.     // ----- unsigned char
  90.     
  91.     void Read(unsigned char* buffer,
  92.               long count) const;
  93.         // Read 'count' unsigned chars into buffer.
  94.  
  95.     const FW_CReadableStream& operator>>(unsigned char& aChar) const;
  96.         // Read char.
  97.  
  98.     unsigned char GetUnsignedChar() const;
  99.         // Get unsigned char.
  100.  
  101.     // ----- int
  102.  
  103.     void Read(int* buffer,
  104.               long count) const;
  105.         // Read 'count' ints into buffer.
  106.  
  107.     const FW_CReadableStream& operator>>(int& aInt) const;
  108.         // Read int.
  109.  
  110.     int GetInt() const;
  111.         // Get int.
  112.  
  113.     // ----- unsigned int
  114.  
  115.     void Read(unsigned int* buffer,
  116.               long count) const;
  117.         // Read 'count' unsigned ints into buffer.
  118.  
  119.     const FW_CReadableStream& operator>>(unsigned int& unsignedInt) const;
  120.         // Read unsigned int.
  121.  
  122.     unsigned int GetUnsignedInt() const;
  123.         // Get unsigned int.
  124.  
  125.     // ----- short
  126.  
  127.     void Read(short* buffer,
  128.               long count) const;
  129.         // Read 'count' shorts into buffer.
  130.  
  131.     const FW_CReadableStream& operator>>(short& aShort) const;
  132.         // Read short.
  133.  
  134.     short GetShort() const;
  135.         // Get short.
  136.  
  137.     // ----- unsigned short
  138.  
  139.     void Read(unsigned short* buffer,
  140.               long count) const;
  141.         // Read 'count' unsigned shorts into buffer.
  142.  
  143.     const FW_CReadableStream& operator>>(unsigned short& unsignedShort) const;
  144.         // Read unsigned short.
  145.  
  146.     unsigned short GetUnsignedShort() const;
  147.         // Get unsigned short.
  148.  
  149.     // ----- long
  150.  
  151.     void Read(long* buffer,
  152.               long count) const;
  153.         // Read 'count' longs into buffer.
  154.  
  155.     const FW_CReadableStream& operator>>(long& aLong) const;
  156.         // Read long.
  157.  
  158.     long GetLong() const;
  159.         // Get long.
  160.  
  161.     // ----- unsigned long
  162.  
  163.     void Read(unsigned long* buffer,
  164.               long count) const;
  165.         // Read 'count' unsigned longs into buffer.
  166.  
  167.     const FW_CReadableStream& operator>>(unsigned long& unsignedLong) const;
  168.         // Read unsigned long.
  169.  
  170.     unsigned long GetUnsignedLong() const;
  171.         // Get unsigned long.
  172.  
  173.     // ----- float
  174.  
  175.     void Read(float* buffer,
  176.               long count) const;
  177.         // Read 'count' floats into buffer.
  178.  
  179.     const FW_CReadableStream& operator>>(float& aFloat) const;
  180.         // Read float.
  181.  
  182.     float GetFloat() const;
  183.         // Get float.
  184.  
  185.     // ----- double
  186.  
  187.     void Read(double* buffer,
  188.               long count) const;
  189.         // Read 'count' doubles into buffer.
  190.  
  191.     const FW_CReadableStream& operator>>(double& aDouble) const;
  192.         // Read double.
  193.  
  194.     double GetDouble() const;
  195.         // Get double.
  196.         
  197. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  198.  
  199.     // ----- long double
  200.     
  201.     void Read(long double* buffer,
  202.               long count) const;
  203.         // Read 'count' long doubles into buffer.
  204.  
  205.     const FW_CReadableStream& operator>>(long double& aDouble) const;
  206.         // Read long double.
  207.  
  208.     long double GetLongDouble() const;
  209.         // Get long double.
  210. #endif
  211.  
  212. protected:
  213.  
  214.     FW_CSink* fSink;
  215.     FW_Boolean fStreamCreatedFormatter;
  216.     FW_CReadableStreamFormatter* fFormatter;
  217.     FW_Boolean fArchiveCreatedObjectRegistry;
  218.     FW_CObjectRegistry* fObjectRegistry;
  219.     
  220. private:
  221.     FW_CReadableStream(const FW_CReadableStream& theStream);
  222.     FW_CReadableStream& operator=(const FW_CReadableStream& theStream);
  223.         // Can't copy instances of this class.
  224. };
  225.  
  226. //----------------------------------------------------------------------------------------
  227. // FW_CReadableStream::GetSink
  228. //----------------------------------------------------------------------------------------
  229.  
  230. inline FW_CSink* FW_CReadableStream::GetSink() const
  231. {
  232.     return fSink;
  233. }
  234.  
  235. //----------------------------------------------------------------------------------------
  236. // FW_CReadableStream::Read
  237. //----------------------------------------------------------------------------------------
  238.  
  239. inline void FW_CReadableStream::Read(void* buffer,
  240.                                      long count) const
  241. {
  242.     fFormatter->ReadBytes(*fSink, buffer, count);
  243. }
  244.  
  245. //#if !defined(__BORLANDC__)
  246. //----------------------------------------------------------------------------------------
  247. // FW_CReadableStream::Read
  248. //----------------------------------------------------------------------------------------
  249.  
  250. inline void FW_CReadableStream::Read(char* buffer,
  251.                                      long count) const
  252. {
  253.     fFormatter->ReadChars(*fSink, buffer, count);
  254. }
  255. //#endif
  256.  
  257. //#if !defined(__BORLANDC__)
  258. //----------------------------------------------------------------------------------------
  259. // FW_CReadableStream::operator >>
  260. //----------------------------------------------------------------------------------------
  261.  
  262. inline const FW_CReadableStream& FW_CReadableStream::operator>>(char& aChar) const
  263. {
  264.     fFormatter->ReadChars(*fSink, &aChar, 1);
  265.     return *this;
  266. }
  267. //#endif
  268.  
  269. //----------------------------------------------------------------------------------------
  270. // FW_CReadableStream::operator >>
  271. //----------------------------------------------------------------------------------------
  272.  
  273. inline const FW_CReadableStream& FW_CReadableStream::operator>>(char* nullTerminatedString) const
  274. {
  275.     fFormatter->ReadNullTerminatedString(*fSink, nullTerminatedString);
  276.     return *this;
  277. }
  278.  
  279. //----------------------------------------------------------------------------------------
  280. // FW_CReadableStream::GetChar
  281. //----------------------------------------------------------------------------------------
  282.  
  283. inline char FW_CReadableStream::GetChar() const
  284. {
  285.     char x;
  286.     fFormatter->ReadChars(*fSink, &x, 1);
  287.     return x;
  288. }
  289.  
  290. //----------------------------------------------------------------------------------------
  291. // FW_CReadableStream::Read
  292. //----------------------------------------------------------------------------------------
  293.  
  294. inline void FW_CReadableStream::Read(signed char* buffer,
  295.                                      long count) const
  296. {
  297.     fFormatter->ReadSignedChars(*fSink, buffer, count);
  298. }
  299.  
  300. //----------------------------------------------------------------------------------------
  301. // FW_CReadableStream::operator >>
  302. //----------------------------------------------------------------------------------------
  303.  
  304. inline const FW_CReadableStream& FW_CReadableStream::operator>>(signed char& aChar) const
  305. {
  306.     fFormatter->ReadSignedChars(*fSink, &aChar, 1);
  307.     return *this;
  308. }
  309.  
  310. //----------------------------------------------------------------------------------------
  311. // FW_CReadableStream::GetSignedChar
  312. //----------------------------------------------------------------------------------------
  313.  
  314. inline signed char FW_CReadableStream::GetSignedChar() const
  315. {
  316.     signed char x;
  317.     fFormatter->ReadSignedChars(*fSink, &x, 1);
  318.     return x;
  319. }
  320.  
  321. //----------------------------------------------------------------------------------------
  322. // FW_CReadableStream::Read
  323. //----------------------------------------------------------------------------------------
  324.  
  325. inline void FW_CReadableStream::Read(unsigned char* buffer,
  326.                                      long count) const
  327. {
  328.     fFormatter->ReadUnsignedChars(*fSink, buffer, count);
  329. }
  330.  
  331. //----------------------------------------------------------------------------------------
  332. // FW_CReadableStream::operator >>
  333. //----------------------------------------------------------------------------------------
  334.  
  335. inline const FW_CReadableStream& FW_CReadableStream::operator>>(unsigned char& aChar) const
  336. {
  337.     fFormatter->ReadUnsignedChars(*fSink, &aChar, 1);
  338.     return *this;
  339. }
  340.  
  341. //----------------------------------------------------------------------------------------
  342. // FW_CReadableStream::GetUnsignedChar
  343. //----------------------------------------------------------------------------------------
  344.  
  345. inline unsigned char FW_CReadableStream::GetUnsignedChar() const
  346. {
  347.     unsigned char x;
  348.     fFormatter->ReadUnsignedChars(*fSink, &x, 1);
  349.     return x;
  350. }
  351.  
  352. //----------------------------------------------------------------------------------------
  353. // FW_CReadableStream::Read
  354. //----------------------------------------------------------------------------------------
  355.  
  356. inline void FW_CReadableStream::Read(int* buffer,
  357.                                      long count) const
  358. {
  359.     fFormatter->ReadInts(*fSink, buffer, count);
  360. }
  361.  
  362. //----------------------------------------------------------------------------------------
  363. // FW_CReadableStream::operator >>
  364. //----------------------------------------------------------------------------------------
  365.  
  366. inline const FW_CReadableStream& FW_CReadableStream::operator>>(int& aInt) const
  367. {
  368.     fFormatter->ReadInts(*fSink, &aInt, 1);
  369.     return *this;
  370. }
  371.  
  372. //----------------------------------------------------------------------------------------
  373. // FW_CReadableStream::GetInt
  374. //----------------------------------------------------------------------------------------
  375.  
  376. inline int FW_CReadableStream::GetInt() const
  377. {
  378.     int x;
  379.     fFormatter->ReadInts(*fSink, &x, 1);
  380.     return x;
  381. }
  382.  
  383. //----------------------------------------------------------------------------------------
  384. // FW_CReadableStream::Read
  385. //----------------------------------------------------------------------------------------
  386.  
  387. inline void FW_CReadableStream::Read(unsigned int* buffer,
  388.                                      long count) const
  389. {
  390.     fFormatter->ReadUnsignedInts(*fSink, buffer, count);
  391. }
  392.  
  393. //----------------------------------------------------------------------------------------
  394. // FW_CReadableStream::operator >>
  395. //----------------------------------------------------------------------------------------
  396.  
  397. inline const FW_CReadableStream& FW_CReadableStream::operator>>(unsigned int& unsignedInt) const
  398. {
  399.     fFormatter->ReadUnsignedInts(*fSink, &unsignedInt, 1);
  400.     return *this;
  401. }
  402.  
  403. //----------------------------------------------------------------------------------------
  404. // FW_CReadableStream::GetUnsignedInt
  405. //----------------------------------------------------------------------------------------
  406.  
  407. inline unsigned int FW_CReadableStream::GetUnsignedInt() const
  408. {
  409.     unsigned int x;
  410.     fFormatter->ReadUnsignedInts(*fSink, &x, 1);
  411.     return x;
  412. }
  413.  
  414. //----------------------------------------------------------------------------------------
  415. // FW_CReadableStream::Read
  416. //----------------------------------------------------------------------------------------
  417.  
  418. inline void FW_CReadableStream::Read(short* buffer,
  419.                                      long count) const
  420. {
  421.     fFormatter->ReadShorts(*fSink, buffer, count);
  422. }
  423.  
  424. //----------------------------------------------------------------------------------------
  425. // FW_CReadableStream::operator >>
  426. //----------------------------------------------------------------------------------------
  427.  
  428. inline const FW_CReadableStream& FW_CReadableStream::operator>>(short& aShort) const
  429. {
  430.     fFormatter->ReadShorts(*fSink, &aShort, 1);
  431.     return *this;
  432. }
  433.  
  434. //----------------------------------------------------------------------------------------
  435. // FW_CReadableStream::GetShort
  436. //----------------------------------------------------------------------------------------
  437.  
  438. inline short FW_CReadableStream::GetShort() const
  439. {
  440.     short x;
  441.     fFormatter->ReadShorts(*fSink, &x, 1);
  442.     return x;
  443. }
  444.  
  445. //----------------------------------------------------------------------------------------
  446. // FW_CReadableStream::Read
  447. //----------------------------------------------------------------------------------------
  448.  
  449. inline void FW_CReadableStream::Read(unsigned short* buffer,
  450.                                      long count) const
  451. {
  452.     fFormatter->ReadUnsignedShorts(*fSink, buffer, count);
  453. }
  454.  
  455. //----------------------------------------------------------------------------------------
  456. // FW_CReadableStream::operator >>
  457. //----------------------------------------------------------------------------------------
  458.  
  459. inline const FW_CReadableStream& FW_CReadableStream::operator>>(unsigned short& unsignedShort) const
  460. {
  461.     fFormatter->ReadUnsignedShorts(*fSink, &unsignedShort, 1);
  462.     return *this;
  463. }
  464.  
  465. //----------------------------------------------------------------------------------------
  466. // FW_CReadableStream::GetUnsignedShort
  467. //----------------------------------------------------------------------------------------
  468.  
  469. inline unsigned short FW_CReadableStream::GetUnsignedShort() const
  470. {
  471.     unsigned short x;
  472.     fFormatter->ReadUnsignedShorts(*fSink, &x, 1);
  473.     return x;
  474. }
  475.  
  476. //----------------------------------------------------------------------------------------
  477. // FW_CReadableStream::Read
  478. //----------------------------------------------------------------------------------------
  479.  
  480. inline void FW_CReadableStream::Read(long* buffer,
  481.                                      long count) const
  482. {
  483.     fFormatter->ReadLongs(*fSink, buffer, count);
  484. }
  485.  
  486. //----------------------------------------------------------------------------------------
  487. // FW_CReadableStream::operator >>
  488. //----------------------------------------------------------------------------------------
  489.  
  490. inline const FW_CReadableStream& FW_CReadableStream::operator>>(long& aLong) const
  491. {
  492.     fFormatter->ReadLongs(*fSink, &aLong, 1);
  493.     return *this;
  494. }
  495.  
  496. //----------------------------------------------------------------------------------------
  497. // FW_CReadableStream::GetLong
  498. //----------------------------------------------------------------------------------------
  499.  
  500. inline long FW_CReadableStream::GetLong() const
  501. {
  502.     long x;
  503.     fFormatter->ReadLongs(*fSink, &x, 1);
  504.     return x;
  505. }
  506.  
  507. //----------------------------------------------------------------------------------------
  508. // FW_CReadableStream::Read
  509. //----------------------------------------------------------------------------------------
  510.  
  511. inline void FW_CReadableStream::Read(unsigned long* buffer,
  512.                                      long count) const
  513. {
  514.     fFormatter->ReadUnsignedLongs(*fSink, buffer, count);
  515. }
  516.  
  517. //----------------------------------------------------------------------------------------
  518. // FW_CReadableStream::operator >>
  519. //----------------------------------------------------------------------------------------
  520.  
  521. inline const FW_CReadableStream& FW_CReadableStream::operator>>(unsigned long& unsignedLong) const
  522. {
  523.     fFormatter->ReadUnsignedLongs(*fSink, &unsignedLong, 1);
  524.     return *this;
  525. }
  526.  
  527. //----------------------------------------------------------------------------------------
  528. // FW_CReadableStream::GetUnsignedLong
  529. //----------------------------------------------------------------------------------------
  530.  
  531. inline unsigned long FW_CReadableStream::GetUnsignedLong() const
  532. {
  533.     unsigned long x;
  534.     fFormatter->ReadUnsignedLongs(*fSink, &x, 1);
  535.     return x;
  536. }
  537.  
  538. //----------------------------------------------------------------------------------------
  539. // FW_CReadableStream::Read
  540. //----------------------------------------------------------------------------------------
  541.  
  542. inline void FW_CReadableStream::Read(float* buffer,
  543.                                      long count) const
  544. {
  545.     fFormatter->ReadFloats(*fSink, buffer, count);
  546. }
  547.  
  548. //----------------------------------------------------------------------------------------
  549. // FW_CReadableStream::operator >>
  550. //----------------------------------------------------------------------------------------
  551.  
  552. inline const FW_CReadableStream& FW_CReadableStream::operator>>(float& aFloat) const
  553. {
  554.     fFormatter->ReadFloats(*fSink, &aFloat, 1);
  555.     return *this;
  556. }
  557.  
  558. //----------------------------------------------------------------------------------------
  559. // FW_CReadableStream::GetFloat
  560. //----------------------------------------------------------------------------------------
  561.  
  562. inline float FW_CReadableStream::GetFloat() const
  563. {
  564.     float x;
  565.     fFormatter->ReadFloats(*fSink, &x, 1);
  566.     return x;
  567. }
  568.  
  569. //----------------------------------------------------------------------------------------
  570. // FW_CReadableStream::Read
  571. //----------------------------------------------------------------------------------------
  572.  
  573. inline void FW_CReadableStream::Read(double* buffer,
  574.                                      long count) const
  575. {
  576.     fFormatter->ReadDoubles(*fSink, buffer, count);
  577. }
  578.  
  579. //----------------------------------------------------------------------------------------
  580. // FW_CReadableStream::operator >>
  581. //----------------------------------------------------------------------------------------
  582.  
  583. inline const FW_CReadableStream& FW_CReadableStream::operator>>(double& aDouble) const
  584. {
  585.     fFormatter->ReadDoubles(*fSink, &aDouble, 1);
  586.     return *this;
  587. }
  588.  
  589. //----------------------------------------------------------------------------------------
  590. // FW_CReadableStream::GetDouble
  591. //----------------------------------------------------------------------------------------
  592.  
  593. inline double FW_CReadableStream::GetDouble() const
  594. {
  595.     double x;
  596.     fFormatter->ReadDoubles(*fSink, &x, 1);
  597.     return x;
  598. }
  599.  
  600. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  601. //----------------------------------------------------------------------------------------
  602. // FW_CReadableStream::Read
  603. //----------------------------------------------------------------------------------------
  604.  
  605. inline void FW_CReadableStream::Read(long double* buffer,
  606.                                      long count) const
  607. {
  608.     fFormatter->ReadLongDoubles(*fSink, buffer, count);
  609. }
  610. #endif
  611.  
  612. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  613. //----------------------------------------------------------------------------------------
  614. // FW_CReadableStream::operator >>
  615. //----------------------------------------------------------------------------------------
  616.  
  617. inline const FW_CReadableStream& FW_CReadableStream::operator>>(long double& aDouble) const
  618. {
  619.     fFormatter->ReadLongDoubles(*fSink, &aDouble, 1);
  620.     return *this;
  621. }
  622. #endif
  623.  
  624. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  625. //----------------------------------------------------------------------------------------
  626. // FW_CReadableStream::GetLongDouble
  627. //----------------------------------------------------------------------------------------
  628.  
  629. inline long double FW_CReadableStream::GetLongDouble() const
  630. {
  631.     long double x;
  632.     fFormatter->ReadLongDoubles(*fSink, &x, 1);
  633.     return x;
  634. }
  635. #endif
  636.  
  637.  
  638. //========================================================================================
  639. //    CLASS FW_CWritableStream
  640. //========================================================================================
  641.  
  642. class FW_CLASS_ATTR FW_CWritableStream FW_AUTO_DESTRUCT_OBJECT
  643. {
  644.  
  645. public:
  646.  
  647.     typedef void (* OutputFunction)(FW_CWritableStream & stream, const void *object);
  648.  
  649.     FW_CWritableStream(FW_CSink* sink,
  650.                        FW_CWritableStreamFormatter* formatter = 0,
  651.                        FW_CObjectRegistry* objectRegistry = 0);
  652.     ~ FW_CWritableStream();
  653.  
  654.     void OutputObject(OutputFunction outputFunction,
  655.                       const void* object);
  656.         // Writes object data for static and dynamic classes to the writableStream.
  657.  
  658.     FW_CSink*    GetSink() const;
  659.     
  660.     // ----- void
  661.     
  662.     void Write(const void* buffer,
  663.                long count) const;
  664.         // Write 'count' bytes from buffer.
  665.  
  666. //#if !defined(__BORLANDC__)
  667.     // Borland doesn't treat char, unsigned char and signed char as three distinct types
  668.     // as it should. (ARM pg. 22)
  669.  
  670.     // ----- char
  671.     
  672.     void Write(const char* buffer,
  673.                long count) const;
  674.         // Write 'count' chars from buffer.
  675.  
  676.     const FW_CWritableStream& operator<<(const char &aChar) const;
  677.         // Write char.
  678. //#endif
  679.  
  680.     const FW_CWritableStream& operator<<(const char *nullTerminatedString) const;
  681.         // Write a null-terminated string.
  682.  
  683.     // ----- signed char
  684.     
  685.     void Write(const signed char* buffer,
  686.                long count) const;
  687.         // Write 'count' signed chars from buffer.
  688.  
  689.     const FW_CWritableStream& operator<<(const signed char &aChar) const;
  690.         // Write signed char.
  691.  
  692.     // ----- unsigned char
  693.     
  694.     void Write(const unsigned char* buffer,
  695.                long count) const;
  696.         // Write 'count' unsigned chars from buffer.
  697.  
  698.     const FW_CWritableStream& operator<<(const unsigned char &aChar) const;
  699.         // Write unsigned char.
  700.  
  701.     // ----- int
  702.  
  703.     void Write(const int* buffer,
  704.                long count) const;
  705.         // Write 'count' ints from buffer.
  706.  
  707.     const FW_CWritableStream& operator<<(const int &aInt) const;
  708.         // Write int.
  709.  
  710.     // ----- unsigned int
  711.  
  712.     void Write(const unsigned int* buffer,
  713.                long count) const;
  714.         // Write 'count' unsigned ints from buffer.
  715.  
  716.     const FW_CWritableStream& operator<<(const unsigned int &unsignedInt) const;
  717.         // Write unsigned int.
  718.  
  719.     // ----- short
  720.  
  721.     void Write(const short* buffer,
  722.                long count) const;
  723.         // Write 'count' shorts from buffer.
  724.  
  725.     const FW_CWritableStream& operator<<(const short &aShort) const;
  726.         // Write short.
  727.  
  728.     // ----- unsigned short
  729.  
  730.     void Write(const unsigned short* buffer,
  731.                long count) const;
  732.         // Write 'count' unsigned shorts from buffer.
  733.  
  734.     const FW_CWritableStream& operator<<(const unsigned short &unsignedShort) const;
  735.         // Write unsigned short.
  736.  
  737.     // ----- long
  738.  
  739.     void Write(const long* buffer,
  740.                long count) const;
  741.         // Write 'count' longs from buffer.
  742.  
  743.     const FW_CWritableStream& operator<<(const long &aLong) const;
  744.         // Write long.
  745.  
  746.     // ----- unsigned long
  747.  
  748.     void Write(const unsigned long* buffer,
  749.                long count) const;
  750.         // Write 'count' unsigned longs from buffer.
  751.  
  752.     const FW_CWritableStream& operator<<(const unsigned long &unsignedLong) const;
  753.         // Write unsigned long.
  754.  
  755.     // ----- float
  756.  
  757.     void Write(const float* buffer,
  758.                long count) const;
  759.         // Write 'count' floats from buffer.
  760.  
  761.     const FW_CWritableStream& operator<<(const float &aFloat) const;
  762.         // Write float.
  763.  
  764.     // ----- double
  765.  
  766.     void Write(const double* buffer,
  767.                long count) const;
  768.         // Write 'count' doubles from buffer.
  769.  
  770.     const FW_CWritableStream& operator<<(const double &aDouble) const;
  771.         // Write double.
  772.  
  773. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  774.  
  775.     // ----- long double
  776.  
  777.     void Write(const long double* buffer,
  778.                long count) const;
  779.         // Write 'count' long doubles from buffer.
  780.  
  781.     const FW_CWritableStream& operator<<(const long double &aDouble) const;
  782.         // Write long double.
  783. #endif
  784.  
  785. protected:
  786.  
  787.     FW_CSink* fSink;
  788.     FW_Boolean fStreamCreatedFormatter;
  789.     FW_CWritableStreamFormatter* fFormatter;
  790.     FW_Boolean fArchiveCreatedObjectRegistry;
  791.     FW_CObjectRegistry* fObjectRegistry;
  792.  
  793. private:
  794.     FW_CWritableStream(const FW_CWritableStream& theStream);
  795.     FW_CWritableStream& operator=(const FW_CWritableStream& theStream);
  796.         // Can't copy instances of this class.
  797. };
  798.  
  799. //----------------------------------------------------------------------------------------
  800. // FW_CWritableStream::GetSink
  801. //----------------------------------------------------------------------------------------
  802.  
  803. inline FW_CSink* FW_CWritableStream::GetSink() const
  804. {
  805.     return fSink;
  806. }
  807.  
  808. //----------------------------------------------------------------------------------------
  809. // FW_CWritableStream::Write
  810. //----------------------------------------------------------------------------------------
  811.  
  812. inline void FW_CWritableStream::Write(const void* buffer,
  813.                                       long count) const
  814. {
  815.     fFormatter->WriteBytes(*fSink, buffer, count);
  816. }
  817.  
  818. //#if !defined(__BORLANDC__)
  819. //----------------------------------------------------------------------------------------
  820. // FW_CWritableStream::Write
  821. //----------------------------------------------------------------------------------------
  822.  
  823. inline void FW_CWritableStream::Write(const char* buffer,
  824.                                       long count) const
  825. {
  826.     fFormatter->WriteChars(*fSink, buffer, count);
  827. }
  828. //#endif
  829.  
  830. //#if !defined(__BORLANDC__)
  831. //----------------------------------------------------------------------------------------
  832. // FW_CWritableStream::operator <<
  833. //----------------------------------------------------------------------------------------
  834.  
  835. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const char &aChar) const
  836. {
  837.     fFormatter->WriteChars(*fSink, &aChar, 1);
  838.     return *this;
  839. }
  840. //#endif
  841.  
  842. //----------------------------------------------------------------------------------------
  843. // FW_CWritableStream::operator<<
  844. //----------------------------------------------------------------------------------------
  845.  
  846. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const char* nullTerminatedString) const
  847. {
  848.     fFormatter->WriteNullTerminatedString(*fSink, nullTerminatedString);
  849.     return *this;
  850. }
  851.  
  852. //----------------------------------------------------------------------------------------
  853. // FW_CWritableStream::Write
  854. //----------------------------------------------------------------------------------------
  855.  
  856. inline void FW_CWritableStream::Write(const signed char* buffer,
  857.                                       long count) const
  858. {
  859.     fFormatter->WriteSignedChars(*fSink, buffer, count);
  860. }
  861.  
  862. //----------------------------------------------------------------------------------------
  863. // FW_CWritableStream::operator <<
  864. //----------------------------------------------------------------------------------------
  865.  
  866. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const signed char &aChar) const
  867. {
  868.     fFormatter->WriteSignedChars(*fSink, &aChar, 1);
  869.     return *this;
  870. }
  871.  
  872. //----------------------------------------------------------------------------------------
  873. // FW_CWritableStream::Write
  874. //----------------------------------------------------------------------------------------
  875.  
  876. inline void FW_CWritableStream::Write(const unsigned char* buffer,
  877.                                       long count) const
  878. {
  879.     fFormatter->WriteUnsignedChars(*fSink, buffer, count);
  880. }
  881.  
  882. //----------------------------------------------------------------------------------------
  883. // FW_CWritableStream::operator <<
  884. //----------------------------------------------------------------------------------------
  885.  
  886. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const unsigned char &aChar) const
  887. {
  888.     fFormatter->WriteUnsignedChars(*fSink, &aChar, 1);
  889.     return *this;
  890. }
  891.  
  892. //----------------------------------------------------------------------------------------
  893. // FW_CWritableStream::Write
  894. //----------------------------------------------------------------------------------------
  895.  
  896. inline void FW_CWritableStream::Write(const int* buffer,
  897.                                       long count) const
  898. {
  899.     fFormatter->WriteInts(*fSink, buffer, count);
  900. }
  901.  
  902. //----------------------------------------------------------------------------------------
  903. // FW_CWritableStream::operator <<
  904. //----------------------------------------------------------------------------------------
  905.  
  906. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const int &aInt) const
  907. {
  908.     fFormatter->WriteInts(*fSink, &aInt, 1);
  909.     return *this;
  910. }
  911.  
  912. //----------------------------------------------------------------------------------------
  913. // FW_CWritableStream::Write
  914. //----------------------------------------------------------------------------------------
  915.  
  916. inline void FW_CWritableStream::Write(const unsigned int* buffer,
  917.                                       long count) const
  918. {
  919.     fFormatter->WriteUnsignedInts(*fSink, buffer, count);
  920. }
  921.  
  922. //----------------------------------------------------------------------------------------
  923. // FW_CWritableStream::operator <<
  924. //----------------------------------------------------------------------------------------
  925.  
  926. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const unsigned int &unsignedInt) const
  927. {
  928.     fFormatter->WriteUnsignedInts(*fSink, &unsignedInt, 1);
  929.     return *this;
  930. }
  931.  
  932. //----------------------------------------------------------------------------------------
  933. // FW_CWritableStream::Write
  934. //----------------------------------------------------------------------------------------
  935.  
  936. inline void FW_CWritableStream::Write(const short* buffer,
  937.                                       long count) const
  938. {
  939.     fFormatter->WriteShorts(*fSink, buffer, count);
  940. }
  941.  
  942. //----------------------------------------------------------------------------------------
  943. // FW_CWritableStream::operator <<
  944. //----------------------------------------------------------------------------------------
  945.  
  946. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const short &aShort) const
  947. {
  948.     fFormatter->WriteShorts(*fSink, &aShort, 1);
  949.     return *this;
  950. }
  951.  
  952. //----------------------------------------------------------------------------------------
  953. // FW_CWritableStream::Write
  954. //----------------------------------------------------------------------------------------
  955.  
  956. inline void FW_CWritableStream::Write(const unsigned short* buffer,
  957.                                       long count) const
  958. {
  959.     fFormatter->WriteUnsignedShorts(*fSink, buffer, count);
  960. }
  961.  
  962. //----------------------------------------------------------------------------------------
  963. // FW_CWritableStream::operator <<
  964. //----------------------------------------------------------------------------------------
  965.  
  966. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const unsigned short &unsignedShort) const
  967. {
  968.     fFormatter->WriteUnsignedShorts(*fSink, &unsignedShort, 1);
  969.     return *this;
  970. }
  971.  
  972. //----------------------------------------------------------------------------------------
  973. // FW_CWritableStream::Write
  974. //----------------------------------------------------------------------------------------
  975.  
  976. inline void FW_CWritableStream::Write(const long* buffer,
  977.                                       long count) const
  978. {
  979.     fFormatter->WriteLongs(*fSink, buffer, count);
  980. }
  981.  
  982. //----------------------------------------------------------------------------------------
  983. // FW_CWritableStream::operator <<
  984. //----------------------------------------------------------------------------------------
  985.  
  986. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const long &aLong) const
  987. {
  988.     fFormatter->WriteLongs(*fSink, &aLong, 1);
  989.     return *this;
  990. }
  991.  
  992. //----------------------------------------------------------------------------------------
  993. // FW_CWritableStream::Write
  994. //----------------------------------------------------------------------------------------
  995.  
  996. inline void FW_CWritableStream::Write(const unsigned long* buffer,
  997.                                       long count) const
  998. {
  999.     fFormatter->WriteUnsignedLongs(*fSink, buffer, count);
  1000. }
  1001.  
  1002. //----------------------------------------------------------------------------------------
  1003. // FW_CWritableStream::operator <<
  1004. //----------------------------------------------------------------------------------------
  1005.  
  1006. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const unsigned long &unsignedLong) const
  1007. {
  1008.     fFormatter->WriteUnsignedLongs(*fSink, &unsignedLong, 1);
  1009.     return *this;
  1010. }
  1011.  
  1012. //----------------------------------------------------------------------------------------
  1013. // FW_CWritableStream::Write
  1014. //----------------------------------------------------------------------------------------
  1015.  
  1016. inline void FW_CWritableStream::Write(const float* buffer,
  1017.                                       long count) const
  1018. {
  1019.     fFormatter->WriteFloats(*fSink, buffer, count);
  1020. }
  1021.  
  1022. //----------------------------------------------------------------------------------------
  1023. // FW_CWritableStream::operator <<
  1024. //----------------------------------------------------------------------------------------
  1025.  
  1026. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const float &aFloat) const
  1027. {
  1028.     fFormatter->WriteFloats(*fSink, &aFloat, 1);
  1029.     return *this;
  1030. }
  1031.  
  1032. //----------------------------------------------------------------------------------------
  1033. // FW_CWritableStream::Write
  1034. //----------------------------------------------------------------------------------------
  1035.  
  1036. inline void FW_CWritableStream::Write(const double* buffer,
  1037.                                       long count) const
  1038. {
  1039.     fFormatter->WriteDoubles(*fSink, buffer, count);
  1040. }
  1041.  
  1042. //----------------------------------------------------------------------------------------
  1043. // FW_CWritableStream::operator <<
  1044. //----------------------------------------------------------------------------------------
  1045.  
  1046. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const double &aDouble) const
  1047. {
  1048.     fFormatter->WriteDoubles(*fSink, &aDouble, 1);
  1049.     return *this;
  1050. }
  1051.  
  1052. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  1053. //----------------------------------------------------------------------------------------
  1054. // FW_CWritableStream::Write
  1055. //----------------------------------------------------------------------------------------
  1056.  
  1057. inline void FW_CWritableStream::Write(const long double* buffer,
  1058.                                       long count) const
  1059. {
  1060.     fFormatter->WriteLongDoubles(*fSink, buffer, count);
  1061. }
  1062. #endif
  1063.  
  1064. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  1065. //----------------------------------------------------------------------------------------
  1066. // FW_CWritableStream::operator <<
  1067. //----------------------------------------------------------------------------------------
  1068.  
  1069. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const long double &aDouble) const
  1070. {
  1071.     fFormatter->WriteLongDoubles(*fSink, &aDouble, 1);
  1072.     return *this;
  1073. }
  1074. #endif
  1075.  
  1076. #if FW_LIB_EXPORT_PRAGMAS
  1077. #pragma lib_export off
  1078. #endif
  1079.  
  1080. #endif
  1081.